Skip to content

kad: Add global_addresses_only option - #668

Open
dmitry-markin wants to merge 4 commits into
masterfrom
dm-only-globals-in-dht
Open

dmitry-markin wants to merge 4 commits into
masterfrom
dm-only-globals-in-dht

Conversation

@dmitry-markin

Copy link
Copy Markdown
Collaborator

Add an option to filter-out non-global addresses received from DHT.

litep2p-side of a fix for paritytech/polkadot-sdk#8631.

@dmitry-markin dmitry-markin self-assigned this Oct 7, 2026

@gab8i gab8i left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

Comment on lines +492 to +496
let mut message = KademliaMessage::from_bytes(message, self.replication_factor)
.ok_or(Error::InvalidData)?;
if self.remote_address_mode == RemoteAddressMode::GlobalOnly {
message.retain_global_addresses();
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: KademliaMessage::from_bytes keeps only the 20 (k replication factor) peers, then we filter out peers that don't have any global addresses. In the first run, we might truncate peers that contain valid global addresses that could contribute to the result after calling retain_global_addresses

Maybe we could pass RemoteAddressMode directly to KademliaMessage::from_bytes?

@lexnv lexnv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🙏

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants